﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
using System.Drawing;
using Website.Logger;
using DAL;
using BOL;
using System.Web.Script.Services;
using System.Web.Services;
using WebLib;
using UtilityExtensions;
using System.Globalization;

namespace UILGestion.ObraAdmin.RecepcionDoc
{
    public partial class RecepcionDocInsertOPT1Form : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                idObra.Value = (string)Request.QueryString["idObra"];
                menuObraCtrl1.loadMenu(int.Parse(idObra.Value), Request.AppRelativeCurrentExecutionFilePath);
                FormatForm();
            }
        }
        private void FormatForm()
        {
            //--------------------
            int idEmpleadoEmisor = int.Parse(System.Web.HttpContext.Current.Session["idEmpleado"].ToString());
            bool acceso = new DAL.FormularioAcceso().VerificarAcceso(DbUtil.Db,
                idEmpleadoEmisor,
                9, //FR
                int.Parse(idObra.Value),
                2); //crear
            //------------------------- 
            // los paneles presentes en el formulario
            OrdenCompraPendRecepDocumentoPanel.Visible = true;
        }
     
        //protected void siguienteButton_Click(object sender, System.EventArgs e)
        //{
        //    try
        //    {
        //        // Create a List to hold the EmployeeID values to delete
               
        //        int idOrdenCompra = 0;
        //        int index = 0;
                
        //        // Iterate through the Employees.Rows property
        //        foreach (ListViewDataItem row in OrdenCompraRecepGrid1.ListView.Items)
        //        {
                    
                   
        //            CheckBox cb = (CheckBox)(row.FindControl("chkEmployeeSelector"));

        //            //solo tomamos un solo proveedor
        //            if (cb != null && cb.Checked)
        //            {
        //                //solo del mismo proveedor

        //                 idOrdenCompra = (int)OrdenCompraRecepGrid1.ListView.DataKeys[row.DisplayIndex][0];

        //                 break;
        //            }
        //        }
        //        if ( idOrdenCompra!=0)
        //        {
        //            Response.Redirect("../ObraAdmin/RecepcionDocInsertForm.aspx?idObra=" + idObra.Value + "&type=A&idOC=" + idOrdenCompra.ToString());
        //        }

        //    }
        //    catch (SqlException sqlex)
        //    {
        //        WebServerSideSqlError.Log(sqlex);
        //        ScriptManager.RegisterClientScriptBlock(this, typeof(Page),
        //         "uniqueKey" + DateTime.Now, "alert('" + sqlex.Message.Replace("'", "") + "');", true);


        //    }
        //    catch (Exception ex)
        //    {
        //        WebServerSideError.Log(ex);
        //        ScriptManager.RegisterClientScriptBlock(this, typeof(Page),
        //         "uniqueKey" + DateTime.Now, "alert('" + ex.Message.Replace("'", "") + "');", true);

        //    }



        //}
    }
}